package top.txl.controller;

import com.aliyun.oss.AliYunUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import top.txl.entity.R;

@RestController
@Slf4j
@CrossOrigin
@RequestMapping("/upload")
public class UploadController {
    @Autowired
    private AliYunUtil aliYunUtil;

    @PostMapping()
    public R<String> upload(MultipartFile file) throws Exception {
        log.info("文件上传",file);
        //  上传文件到阿里云
        String url = aliYunUtil.upload(file);
        return R.success(url);
    }
}
